﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQ_DTO;
// MinhKhoa
namespace DAO
{
    public class LoaiSanPhamGocDAO
    {
        public List<shop_loaisanphamgoc> LayTatCaLoaiSanPhamGoc()
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var products = from a in EFashionDB.shop_loaisanphamgocs select a;
            return products.ToList();
        }
        public void ThemLoaiSanPhamGoc(shop_loaisanphamgoc AddObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            EFashionDB.shop_loaisanphamgocs.InsertOnSubmit(AddObject);
            EFashionDB.SubmitChanges();
        }
        public void XoaLoaiSanPhamGoc(int Ma)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_loaisanphamgocs
                                    where a.MaLoaiSanPhamGoc == Ma
                                        select a;
            shop_loaisanphamgoc Result = ListResultQuery.Single();
            EFashionDB.shop_loaisanphamgocs.DeleteOnSubmit(Result);
            EFashionDB.SubmitChanges();
        }
        public void CapNhatLoaiSanPhamGoc(int Ma, shop_loaisanphamgoc EditObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_loaisanphamgocs
                          where a.MaLoaiSanPhamGoc == Ma
                          select a;
            shop_loaisanphamgoc Result = ListResultQuery.Single();
            Result.TenLoaiSanPhamGoc = EditObject.TenLoaiSanPhamGoc;
            EFashionDB.SubmitChanges();
        }
    }
}
